﻿<!DOCTYPE html>

<html>
<head>
    <meta charset="utf8" />
    <title>JS测试</title>
    <script type="text/javascript">
        function CppToJs(data) {
			alert(data);
            nativemsg.innerText=data;
        }
        function sendmsg2QT() {
           if(!isEmpty(textedit.value)){
				window.ReceivedMsgFromJS(textedit.value);
			}else{
				alert("输入不能为空")
			}
        }
		function isEmpty(str) {
				if(str === undefined) {
					return true;
				}
				else if(str == null) {
					return true;
				} else {
					var reg = /^\s*$/;
					return reg.test(str);
				}
			}
    </script>
<script>

</script>

</head>
<body>
    JS端
    <input type="button"  value="发送消息" onclick='sendmsg2QT()'/>
	<br>
    <br>
    <input type="text" id="textedit" name="textedit"  value=""/>
    <br>
    <br>
	<div style="background-color:#eef">收到消息:<span id="nativemsg" style="font-size:15pt;word-wrap:break-word"></span></div>
</body>
</html>